import TableData from "@/components/waterManage/public/el-tables"; //主页面列表
import formJs from "./regexDetail.js"; //新增弹框配置项
// import entryledgerDialog from "@/view/rawMaterialManage/entryLedgerText/index.vue";
import checkSampleDialog from "@/components/sampleManage/fieldSampling/index.vue";
// 外委不合格报告
// import outDialog from "@/components/outsourcedManage/outUnQualifiedReports/index.vue";
// 混凝土
import hunnintuDialog from "@/components/machineNetworkManage/pressDataMonitor/index.vue";
// 钢筋
import gangjinDialog from "@/components/machineNetworkManage/zigzagDataMonitor/index.vue";
// 水泥不合格
import shuiniDialog from "@/components/machineNetworkManage/compressivePressDataMonitor/index.vue";
// 外委合格
// import outhegeDialog from "@/components/outsourcedManage/qualificationReport/index.vue";
// 试验检测管理不合格
// import testDialog from "@/components/testDetectionManage/unqualifiedReport/index.vue";
// 试验机联网闭合
// import biheDialog from "@/components/machineNetworkManage/pressDataProcess/index.vue";
import FormLyout from '@/components/commonPublic/fromLayout.vue'
import messageBox from "@/components/public/messageBox"; //主页面分页

import {
    getledgerByFid, //详情
} from "@/api/request.js";
export default {

    data() {
        return {
            visible: "",
            showMsgBox: false,
            msgTip: "请先选中数据行！",
            msgType: 1,
            loading: false,
            entryledger_config: formJs.entryledger_config, //进场批次
            checkSample_config: formJs.checkSample_config, // 样品取样
            checkSamples_config: formJs.checkSamples_config, // 样品收样
            testMortarFlexural_config: formJs.testMortarFlexural_config, // 试验机监控
            report_config: formJs.report_config, //检测报告
            Nonreport_config: formJs.Nonreport_config, //不i合格报告
            displaySwitching: null,
            isLock: false,
            btnStatus: [],
            dialogHeight: null,
            currntData: null,
            dataInfo: null,
            startDates: null,
            treeData: [], //材料种类
            tableData: [],
            currentDetail: null,
            listLoading: true,
            rowDetail: null,
            entryledgerShow: false, //进场
            checkSampleShow: false, //取样
            outShow: false, //外委不合格报告
            hunnintuShow: false, //混凝土不合格
            gangjinShow: false, //钢筋
            shuiniShow: false, //水泥
            outhegeShow: false, //外委合格
            testShow: false, // 试验检测管理不合格
            biheShow: false, //试验机联网闭合
            tableTitle: null,
            flagNum: null,
            keyType: null,
            closeType: null,
            primaryInfo:null
        };
    },
    components: {
        TableData,
        // entryledgerDialog, //进场
        checkSampleDialog, //样品取样
        // outDialog, //外委不合格报告
        hunnintuDialog, //混凝土不合格
        gangjinDialog, //钢筋不合格
        shuiniDialog, // 水泥不合格
        // outhegeDialog, //外委合格
        // testDialog, // 试验检测管理不合格
        // biheDialog, // 试验机联网闭合
        FormLyout,
        messageBox

    },
    watch: {},

    mounted() {
        // this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
        this.btnShow = true
        this.primaryInfo = JSON.parse(sessionStorage.getItem("GxEmbedded_primaryInfoRow"))
        if (this.primaryInfo.status == 7) { //查看
            this.getDetail({
                fId: this.primaryInfo.data.fId
            })

        }

    },
    methods: {
        confirmMsg() {
            this.showMsgBox = false;
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
        ClickOnLine(row, status) {
            this.rowDetail = row
            var data;
            if (status == 0) { //进场批次
                this.$router.push({
                    path: "/entryLedgerManage/entryLedgerText",

                });
                data = {
                    data: row,
                    // fCompanyid: this.getList.fCompanyid,
                    status: 7
                }
                
                sessionStorage.setItem(
                    "GxEmbedded_primaryInfo",
                    JSON.stringify(data)
                );
                
            } else if (status == 1) { //取样
                this.displaySwitching = 0;
                this.$router.push({
                    path: "/sampleManage/fieldSamplingText",

                });
                data = {
                    data: row,
                    getList: this.primaryInfo.fCompanyid,
                    status: 7,
                    displaySwitching:0,
                    changeBtn: false,
                }
                sessionStorage.setItem("GxSampleManage_fieldSampling", JSON.stringify(data));

            
                // this.checkSampleShow = true;
            } else if (status == 2) { //收样
                this.displaySwitching = 2;
                // this.checkSampleShow = true;
                this.$router.push({
                    path: "/sampleManage/fieldSamplingText",

                });
                data = {
                    data: row,
                    getList: this.primaryInfo.fCompanyid,
                    status: 7,
                    displaySwitching:2,
                    changeBtn: true,
                }
                sessionStorage.setItem(
                    "GxSampleManage_fieldSampling",
                    JSON.stringify(data)
                );
            } else if (status == 3) { //试验机联网
                if (row.SYLX == '芯样强度') {
                    this.hunnintuShow = true;
                    this.tableTitle = "水泥混凝土芯样强度原始采集数据记录";
                } else if (row.SYLX == '抗折强度') {
                    this.hunnintuShow = true;
                    this.tableTitle = "水泥混凝土抗折强度原始采集数据记录";
                } else if (row.SYLX == '抗压强度') {
                    this.hunnintuShow = true;
                    this.tableTitle = "水泥混凝土抗压强度原始采集数据记录";
                } else if (row.SYLX == '钢筋试验') {
                    this.flagNum = 1
                    this.gangjinShow = true;
                    this.tableTitle = "金属拉伸试验原始采集数据记录";
                } else if (row.SYLX == '钢筋焊接') {
                    this.flagNum = 2
                    this.gangjinShow = true;
                    this.tableTitle = "钢筋焊接接头试验原始采集数据记录";
                } else if (row.SYLX == '机械连接') {
                    this.tableTitle = "钢筋机械连接接头试验原始采集数据记录";
                    this.flagNum = 3
                    this.gangjinShow = true;
                } else if (row.SYLX == '水泥胶砂抗压') {
                    this.shuiniShow = true;
                    this.flagNum = 1
                    this.keyType = row.SYLX

                    this.tableTitle = "水泥抗压强度原始采集数据记录";
                } else if (row.SYLX == '水泥胶砂抗折') {
                    this.shuiniShow = true;
                    this.flagNum = 2
                    this.keyType = row.SYLX

                    this.tableTitle = "水泥胶砂抗折强度试验原始采集数据记录";
                } else if (row.SYLX == '水泥净浆抗压') {
                    this.shuiniShow = true;
                    this.tableTitle = "水泥净浆抗压强度试验原始采集数据记录";
                    this.flagNum = 3
                    this.keyType = row.SYLX

                } else if (row.SYLX == '水泥净浆抗折') {
                    this.shuiniShow = true;
                    this.tableTitle = "水泥净浆抗折强度试验原始采集数据记录";
                    this.flagNum = 4
                    this.keyType = row.SYLX

                } else if (row.SYLX == '水泥砂浆抗压') {
                    this.shuiniShow = true;
                    this.tableTitle = "水泥砂浆抗压强度试验原始采集数据记录";
                    this.flagNum = 5
                    this.keyType = row.SYLX
                }
            } else if (status == 4) { //检测报告
                console.log(row);
                // 外委
                if (row.fChecktype == '监理外委' || row.fChecktype == '施工外委') { //检测类型

                this.$router.push({
                    path: "/outsourcedManage/qualificationReportText",

                });
                data = {
                    data: row,
                    // fCompanyid: this.getList.fCompanyid,
                    status: 7
                }
                
                sessionStorage.setItem(
                    "GxEmbedded_primaryInfo",
                    JSON.stringify(data)
                );
                
                
                // this.outhegeShow = true;
                } else { //自检
                    // 链接
                    if (row.fReporturl != "/" && row.fReporturl != "" && row.fReporturl != null) {
                        window.open(row.fReporturl, '_blank');
                    } else {
                        this.showMsgBox = true;
                        this.msgTip = "试验报告暂未出具"

                    }
                }
            } else if (status == 5) { //不合格报告
                console.log(row);
                // 外委
                if (row.type == '试验机监控') { //检测类型
                    // this.biheShow = true;
                    this.$router.push({
                        path: "machineNetworkManage/pressDataProcessText",
    
                    });
                    if (row.SYLX == '芯样强度') {
                        
                        data = {
                            data: row,
                            closeType:1,
                            tableTitle:"水泥混凝土芯样强度原始采集数据记录",
                            status: 7
                        }
                        // this.closeType = "1"
                        // this.tableTitle = "水泥混凝土芯样强度原始采集数据记录";
                    } else if (row.SYLX == '抗折强度') {
                        data = {
                            data: row,
                            closeType:1,
                            tableTitle:"水泥混凝土抗折强度原始采集数据记录",
                            status: 7
                        }
                        // this.closeType = "1"
                        // this.tableTitle = "水泥混凝土抗折强度原始采集数据记录";
                    } else if (row.SYLX == '抗压强度') {
                        data = {
                            data: row,
                            closeType:1,
                            tableTitle:"水泥混凝土抗压强度原始采集数据记录",
                            status: 7
                        }
                        // this.closeType = "1"
                        // this.tableTitle = "水泥混凝土抗压强度原始采集数据记录";
                    } else if (row.SYLX == '钢筋试验') {
                        data = {
                            data: row,
                            closeType:2,
                            tableTitle:"金属拉伸试验原始采集数据记录",
                            status: 7,
                            flagNum:1
                        }
                        // this.flagNum = 1
                        // this.closeType = "2"
                        // this.tableTitle = "金属拉伸试验原始采集数据记录";
                    } else if (row.SYLX == '钢筋焊接') {
                        data = {
                            data: row,
                            closeType:2,
                            tableTitle:"钢筋焊接接头试验原始采集数据记录",
                            status: 7,
                            flagNum:2
                        }
                        // this.flagNum = 2
                        // this.closeType = "2"
                        // this.tableTitle = "钢筋焊接接头试验原始采集数据记录";
                    } else if (row.SYLX == '机械连接') {
                        // this.tableTitle = "钢筋机械连接接头试验原始采集数据记录";
                        // this.flagNum = 3
                        // this.closeType = "2"
                        data = {
                            data: row,
                            closeType:2,
                            tableTitle:"钢筋机械连接接头试验原始采集数据记录",
                            status: 7,
                            flagNum:3
                        }

                    } else if (row.SYLX == '水泥胶砂抗压') {
                        // this.closeType = 3;
                        // this.flagNum = 1
                        // this.keyType = row.SYLX
                        data = {
                            data: row,
                            closeType:3,
                            status: 7,
                            flagNum:1,
                            keyType:row.SYLX,
                            tableTitle:"水泥抗压强度原始采集数据记录"
             
                        }

                        // this.tableTitle = "水泥抗压强度原始采集数据记录";
                    } else if (row.SYLX == '水泥胶砂抗折') {
                        data = {
                            data: row,
                            closeType:3,
                            status: 7,
                            flagNum:2,
                            keyType:row.SYLX,
                            tableTitle:"水泥胶砂抗折强度试验原始采集数据记录"
             
                        }
                        // this.flagNum = 2
                        // this.keyType = row.SYLX
                        // this.closeType = 3;
                        // this.tableTitle = "水泥胶砂抗折强度试验原始采集数据记录";
                    } else if (row.SYLX == '水泥净浆抗压') {
                        // this.closeType = 4;
                        // this.tableTitle = "水泥净浆抗压强度试验原始采集数据记录";
                        // this.flagNum = 3
                        // this.keyType = row.SYLX
                        data = {
                            data: row,
                            closeType:4,
                            status: 7,
                            flagNum:3,
                            keyType:row.SYLX,
                            tableTitle:"水泥净浆抗压强度试验原始采集数据记录"
             
                        }

                    } else if (row.SYLX == '水泥净浆抗折') {
                        data = {
                            data: row,
                            closeType:4,
                            status: 7,
                            flagNum:4,
                            keyType:row.SYLX,
                            tableTitle:"水泥净浆抗折强度试验原始采集数据记录"
             
                        }
                        // this.closeType = 4;
                        // this.tableTitle = "水泥净浆抗折强度试验原始采集数据记录";
                        // this.flagNum = 4
                        // this.keyType = row.SYLX

                    } else if (row.SYLX == '水泥砂浆抗压') {
                        data = {
                            data: row,
                            closeType:5,
                            status: 7,
                            flagNum:5,
                            keyType:row.SYLX,
                            tableTitle:"水泥砂浆抗压强度试验原始采集数据记录"
                        }
                        // this.closeType = 5;
                        // this.tableTitle = "水泥砂浆抗压强度试验原始采集数据记录";
                        // this.flagNum = 5
                        // this.keyType = row.SYLX
                    }

                    sessionStorage.setItem(
                        "GxEmbedded_primaryInfo",
                        JSON.stringify(data)
                    );
                } else if (row.type == '检测报告') { //自检
                    // 外委
                    if (row.fChecktype == '监理外委' || row.fChecktype == '施工外委') { //检测类型
                    //
                    this.$router.push({
                        path: "/outsourcedManage/outUnQualifiedReportsText",
    
                    });
                    data = {
                        data: row,
                        // fCompanyid: this.getList.fCompanyid,
                        status: 7
                    }
                    
                    sessionStorage.setItem(
                        "GxEmbedded_primaryInfo",
                        JSON.stringify(data)
                    );
                    
                    // this.outShow = true;
                    } else { //自检 // 试验检测管理不合格
                        this.testShow = true
                        this.$router.push({
                            path: "/testDetectionManage/unqualifiedReportText",
                        });
                        data = {
                            data: row,
                            // fCompanyid: this.getList.fCompanyid,
                            status: 7
                        }
                        sessionStorage.setItem(
                            "GxEmbedded_primaryInfo",
                            JSON.stringify(data)
                        );
                    }
                }
            }
        },
        biheCloseDialog() { //试验及联网闭合
            this.biheShow = false
        },
        entryledgerCloseDialog() { //进场批次
            this.entryledgerShow = false
        },
        checkSampleCloseDialog() { //取样
            this.checkSampleShow = false
        },
        // outhegeCloseDialog() { //外委合格报告
        //     this.outhegeShow = false
        // },
        // outCloseDialog() { //外委不合格报告
        //     this.outShow = false
        // },
        hunnintuCloseDialog() { //混凝土不合格报告
            this.hunnintuShow = false
        },
        gangjinCloseDialog() { //钢筋不合格报告
            this.gangjinShow = false
        },
        // testCloseDialog() { // 试验检测管理不合格
        //     this.testShow = false
        // },
        // 详情
        getDetail(obj) {
            this.loading = true;
            getledgerByFid(obj).then((res) => {
                if (res.errcode == 0) {
                    var data = res.data
                    this.loading = false;

                    this.listLoading = false
                    this.tableData = data
                } else {
                    this.loading = false;
             
                    this.$message.error({
                        content: res.msg,
                        duration: 1000
                    })
                }
            });
        },
    },
};